<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="groupname">alt.binaries.lsm</xsl:param>
<xsl:param name="pageindex">1</xsl:param>
<xsl:param name="item"/>
<xsl:param name="index"/>
<xsl:param name="UI_PAGE_SIZE">8</xsl:param>
<xsl:param name="PAGE_MAX">10</xsl:param>


 
<xsl:variable name="num" select="count(/list/article)"/>
	    
<xsl:variable name="min" select="1 + (floor (($pageindex - 1) div $PAGE_MAX) * $PAGE_MAX)"/>
<xsl:variable name="max" select="$min + $PAGE_MAX"/>
<xsl:variable name="hi"  select="$pageindex * $UI_PAGE_SIZE"/>
<xsl:variable name="low" select="$hi - $UI_PAGE_SIZE"/> 
<xsl:variable name="sz"  select="floor($num div $UI_PAGE_SIZE)"/> 
<xsl:variable name="chosen"  select="//article[contains(id, $item)]"/> 


<xsl:template match="/">
  <html>
        <link rel='stylesheet' href='/nntp.css?234' type='text/css'/>
		<script language='javascript' src='/images.js?52467'></script>
  <body onload="attach()">
  
		<xsl:choose>
			<xsl:when test="string-length($index) &gt; 0">
				
				<a href="/x/groupname/{$groupname}/pageindex/{$pageindex}"><xsl:value-of select="$groupname"/></a>
				 &#187; 
				<xsl:value-of select="$chosen/subject"/>
				<div align="center">
				<img id='box' src="/ui/image/group/{$groupname}/id/{$chosen/id}/thumb/large"/>
				</div>
				
				<div align="center">
				<select onchange="location.href=this.className+this.options[this.selectedIndex].value;" class="/ui/commandhandler/request/index/index/{$index}/group/{$groupname}/page/{$pageindex}/response/xsl/item/">
					<xsl:for-each select="//article[@index=$index]/items/article">
				      	<xsl:sort select="subject"/>
						<option value="{id}"><xsl:value-of select="subject"/></option>
					</xsl:for-each>
				</select>
				</div>
				
			</xsl:when>
			<xsl:otherwise>
				
				  <xsl:call-template name="navbar"/>
				  
				  <select class="/ui/commandhandler/request/group/response/xsl/group/" onchange="location.href=this.className+this.options[this.selectedIndex].value;">
				  	<xsl:apply-templates select="//group"/>
				  </select>
				  	<hr/>
				  <xsl:apply-templates select="/list/article">
				  	<xsl:sort select="subject"/>
				  </xsl:apply-templates>  
				  
			</xsl:otherwise>
		</xsl:choose>
		 

  
  
  </body>
  </html>
</xsl:template>
 

<xsl:template name="navbar">
	
	    <xsl:if test="$pageindex &gt; 1">
	    	<a href="/ui/commandhandler/request/page/group/{$groupname}/page/{$pageindex - 1}/response/xsl">Prev</a> - 
	    </xsl:if>

	    <xsl:if test="$min &gt; $PAGE_MAX">
	    	<a href="/ui/commandhandler/request/page/group/{$groupname}/page/1/response/xsl">1</a> - 
	    	<a href="/ui/commandhandler/request/page/group/{$groupname}/page/{$min - 1}/response/xsl">...</a> 
	    </xsl:if> 
	    
	<xsl:call-template name="navbar.ex"/>
	
	    <xsl:if test="$max &lt; $sz">
	    	<a href="/ui/commandhandler/request/page/group/{$groupname}/page/{$max}/response/xsl">...</a> - 
	    	<a href="/ui/commandhandler/request/page/group/{$groupname}/page/{$sz}/response/xsl"><xsl:value-of select="$sz"/></a> - 
	    </xsl:if>  
	
	    <xsl:if test="$pageindex &lt; $sz">
	    	<a href="/ui/commandhandler/request/page/group/{$groupname}/page/{$pageindex + 1}/response/xsl">Next</a> 
	    </xsl:if> 
	    
</xsl:template>
 

<xsl:template name="navbar.ex">
	<xsl:param name="i" select="$min"/> 
	<xsl:if test="($i &lt; $max) and ($i &lt; $sz)"> 
		
		<xsl:choose>
			<xsl:when test="$i = $pageindex">
				<b><xsl:value-of select="$i"/></b>
			</xsl:when>
			<xsl:otherwise>
				<a href="/ui/commandhandler/request/page/group/{$groupname}/page/{$i}/response/xsl"><xsl:value-of select="$i"/></a>
			</xsl:otherwise>
		</xsl:choose>
		 
		 - 
		<xsl:call-template name="navbar.ex">
			<xsl:with-param name="i" select="$i + 1"/>
		</xsl:call-template>
	</xsl:if>
</xsl:template>
 

<xsl:template match="group">
	<option>
		<xsl:if test="$groupname=.">
			<xsl:attribute name="selected">selected</xsl:attribute>
		</xsl:if>
		<xsl:value-of select="."/></option>
</xsl:template>
 

<xsl:template match="list/article">
   <xsl:variable name="key"><xsl:choose>
			<xsl:when test="contains(id, '-')"><xsl:value-of select="substring-before(id, '-')"/></xsl:when>
			<xsl:otherwise><xsl:value-of select="id"/></xsl:otherwise>
		</xsl:choose></xsl:variable>
		
 	<xsl:if test="(position() &gt; $low) and (position() &lt; ($hi + 1))">
  <div class="frame"> 
  	<xsl:if test="type='picture'">
  	    <table cellspacing='0' cellpadding='4' width='100%' height='200'><tr><td align='center'>
  	    	<a href="/ui/commandhandler/request/index/index/{@index}/item/{$key}/group/{$groupname}/page/{$pageindex}/response/xsl">
  		<img onload='preload(this,this.className)' src="/images/clear.gif" class="/ui/image/group/{$groupname}/id/{id}/thumb/ok"/>
  		</a>
  		</td></tr></table> 
  	</xsl:if>
  	<xsl:value-of select="count(./items/article)"/> items
  	<br/>
  <xsl:value-of select="subject"/>
  	
  </div>
   </xsl:if>
  
</xsl:template>

</xsl:stylesheet>
